package com.knowledge.graph.service.impl;

import com.knowledge.graph.dataSource.DataSource;
import com.knowledge.graph.dataSource.DataSourceRegistry;
import com.knowledge.graph.model.vo.ResponseVO;
import com.knowledge.graph.model.vo.StatusCode;
import com.knowledge.graph.service.SearchService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.List;

@Service
public class SearchServiceImpl implements SearchService {

    @Resource
    private DataSourceRegistry dataSourceRegistry;

    @Override
    public ResponseVO dosearch(String text) throws IOException {
        if (text == null)
            return new ResponseVO(StatusCode.FAIL_SELECT.getCode(), StatusCode.FAIL_SELECT.getMessage());
        DataSource courseSource = dataSourceRegistry.getDataSource("courseSource");
        ResponseVO responseVO = courseSource.doSearch(text);
        return responseVO;
    }
}
